package concurrent.atomic;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.LongAdder;

public class LongAdderTest {
    private static LongAdder longAdder = new LongAdder();
    static CountDownLatch countDownLatch = new CountDownLatch(1000);
    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {
                longAdder.decrement();
                countDownLatch.countDown();
            }).start();
        }
        countDownLatch.await();
        System.out.println(longAdder.longValue());
    }
}
